--[[ Written by Darryl123 Modified by Tronex: - gather all eneclopedia handlers in one place - custom articles for special cases --]] ------------------------------- -- Controls ------------------------------- local categories = {} local interactivity = {} local unlocked_articles = {} local locked_articles = {} local unlocked_notes = {} local locked_notes = {} function get_articles_count() return get_articles_locked_count() + get_articles_unlocked_count() end function get_articles_locked_count() return size_table(locked_articles) end function get_articles_unlocked_count() return size_table(unlocked_articles) end function get_notes_count() return get_notes_locked_count() + get_notes_unlocked_count() end function get_notes_locked_count() return size_table(locked_notes) end function get_notes_unlocked_count() return size_table(unlocked_notes) end function is_unlocked_article(section) return unlocked_articles[section] and (not locked_articles[section]) and true or false end function is_unlocked_note(section) return unlocked_notes[section] and (not locked_notes[section]) and true or false end function unlock_article(section) if (not section) then return false end -- Return if all articles have been unlocked. if (get_articles_locked_count() == 0) then return false end -- Return if the specified article is already unlocked or doesn't exist. if is_unlocked_article(section) then return false end -- Update the required tables. locked_articles[section] = nil unlocked_articles[section] = true game_statistics.increment_statistic("articles") -- Set article in PDA set_article(section) -- Show idicator and play sound effect -- Old World Addon - Removed --actor_menu.set_notification(nil, "ui_inGame2_notify_article", 20, "device\\pda\\pda_guide_2") --[[ -- Set the article and retrieve the indices. local index_a, index_c = set_article(section) if not (index_a and index_c) then return false end -- Send a message about unlocking the article. if (axr_main.config:r_value("pda_encyclopedia", "display_messages", 1, true)) then -- Article and category texts. local message = game.translate_string("pda_encyclopedia_notify") local text_c = game.translate_string(categories[index_c].section) local text_a text_a = categories[index_c].articles[index_a] text_a = UpdateName(text_a) text_a = game.translate_string(text_a) -- Other information. local header = game.translate_string("st_tip") local texture = news_manager.tips_icons["guide_unlock"] or "ui_inGame2_Poslednie_razrabotki" db.actor:give_game_news(header, strformat(message, text_c, text_a), texture, 0, 5000, 0) utils_obj.play_sound("device\\pda\\pda_guide_2") --utils_obj.play_sound("device\\pda\\pda_guide") end --]] return true end function unlock_all_articles() -- Return if all articles have been unlocked. if (get_articles_locked_count() == 0) then return false end local cnt = 0 for section,_ in pairs(locked_articles) do cnt = cnt + 1 locked_articles[section] = nil unlocked_articles[section] = true game_statistics.increment_statistic("articles") end return cnt end function unlock_note(section) if (not section) then return false end -- Return if all notes have been unlocked. if (get_notes_locked_count() == 0) then return false end -- Return if the specified article is already unlocked or doesn't exist. if is_unlocked_note(section) then return false end -- Update the required tables. locked_notes[section] = nil unlocked_notes[section] = true game_statistics.increment_statistic("notes") -- Set note in PDA set_article(section) -- Show idicator and play sound effect actor_menu.set_notification(nil, "ui_inGame2_notify_article", 20, "device\\pda\\pda_note") --[[ -- Set the article and retrieve the indices. local index_a, index_c = set_article(section) if not (index_a and index_c) then return false end -- Send a message about unlocking the article. if (axr_main.config:r_value("pda_encyclopedia", "display_messages", 1, true)) then -- Article and category texts. local message = game.translate_string("pda_encyclopedia_notify_note") local text_a text_a = categories[index_c].articles[index_a] text_a = UpdateName(text_a) text_a = game.translate_string(text_a) -- Other information. local header = game.translate_string("st_tip") local texture = "ui_iconsTotal_bar_darklab_documents" --news_manager.tips_icons["guide_unlock"] or "ui_inGame2_Poslednie_razrabotki" db.actor:give_game_news(header, strformat(message, text_a), texture, 0, 5000, 0) utils_obj.play_sound("device\\pda\\pda_note") end --]] return true end function unlock_all_notes() -- Return if all articles have been unlocked. if (get_notes_locked_count() == 0) then return false end local cnt = 0 for section,_ in pairs(locked_notes) do cnt = cnt + 1 locked_notes[section] = nil unlocked_notes[section] = true game_statistics.increment_statistic("notes") end return cnt end function set_article(section) -- Instance of the guide object. local guide = get_ui() -- Return if no section exists. if not (section) then return end -- Discover the category of the article. local article = nil local category = nil for index_c = 1, #categories do category = categories[index_c] -- Determine if the article is in this category. if (category) then for index_a = 1, #category.articles do article = category.articles[index_a] -- Set the category and article if correct. if (article and article == section) then -- Refresh and select the categories and articles guide:InitCategories() guide:SelectCategory(category.section) guide:SelectArticle(article) return index_a, index_c end end end end end ------------------------------- -- Initializing ------------------------------- local function evaluate_article(modes, section, value) -- Information about the article. local disabled = nil local tier = 0 local special = nil local unlocked = nil -- Check each value attached to the article. if (value) then for k, v in string.gmatch(value, "([%w_%-%s%.]+)=([%w_%-%s%.]+)") do -- Value read from article flag. local v_bool = ((tonumber(v) or 0) ~= 0) local v_numb = (tonumber(v) or 0) -- Unlocks the article by default. if (k == "unlocked") then unlocked = v_bool -- Tiers the article. elseif (k == "tier") then tier = v_numb > 0 and v_numb or 0 -- Special elseif (k == "special") then special = v_bool -- Enables/disables article based on game mode. elseif (not disabled) then for k2, v2 in pairs(modes) do if (k == k2) then if (v2 and not v_bool) or (v_bool and not v2) then disabled = true break end end end end end end -- Prevents the article being added. if (disabled) then return false end -- Lock or unlock the appropriate notes. if string.find(section,"encyclopedia__notes") then if (unlocked or unlocked_notes[section]) then unlocked_notes[section] = true else locked_notes[section] = tier end -- Lock or unlock the appropriate articles. else if (unlocked or unlocked_articles[section]) then unlocked_articles[section] = true else locked_articles[section] = tier end end -- Article can be added. return true end function parse_categories() -- Step 1: interactivity local modes = { ["azazel"] = IsAzazelMode(), ["debug"] = DEV_DEBUG, ["dev_debug"] = DEV_DEBUG_DEV, ["ironman"] = IsHardcoreMode(), ["story"] = IsStoryMode(), ["survival"] = IsSurvivalMode(), ["campfire"] = IsCampfireMode(), ["agony"] = IsAgonyMode(), ["timer"] = IsTimerMode(), ["warfare"] = _G.WARFARE } -- Return if the encyclopedia plugin does not exist. local ini_ecy = ini_file("plugins\\encyclopedia.ltx") local plugin_section = "encyclopedia" if not (ini_ecy:section_exist(plugin_section)) then return end -- Create a table for each encyclopedia category. local line_count = ini_ecy:line_count(plugin_section) or 0 for i = 0, line_count - 1 do local junk1, section, junk2 = ini_ecy:r_line(plugin_section, i, "", "") categories[i + 1] = { section = section } end -- Fill the categories with their articles. for i = 1, #categories do if (ini_ecy:section_exist(categories[i].section)) then line_count = ini_ecy:line_count(categories[i].section) or 0 categories[i].articles = {} for j = 0, line_count - 1 do local junk1, section, value = ini_ecy:r_line(categories[i].section, j, "", "") if (evaluate_article(modes, section, value) == true) then table.insert(categories[i].articles, section) end end else printf("Encyclopedia category \"" .. categories[i].section .. "\" does not exist.") end end -- Step 2: interactivity -- Return if the encyclopedia interactivity plugin does not exist. local ini_ecy2 = ini_file("plugins\\encyclopedia_interactivity.ltx") local plugin_section = "encyclopedia_interactivity" if not (ini_ecy2:section_exist(plugin_section)) then printf("Encyclopedia interactivity section \"" .. plugin_section .. "\" does not exist.") return end -- Create a match-list of each key with a section. local plugin_sections = {} local line_count = ini_ecy2:line_count(plugin_section) or 0 for i = 0, line_count - 1 do local junk1, section, value = ini_ecy2:r_line(plugin_section, i, "", "") plugin_sections[section] = value end -- Create a table for each key, and fill it with its contents. for match_key, match_section in pairs (plugin_sections) do interactivity[match_key] = {} line_count = ini_ecy2:line_count(match_section) or 0 for i = 0, line_count - 1 do local junk1, section, value = ini_ecy2:r_line(match_section, i, "", "") local values = str_explode(value, ",") interactivity[match_key][section] = {} for j = 1, #values do table.insert(interactivity[match_key][section], values[j]) end end end end ------------------------------- -- Interaction ------------------------------- -- Delays interaction until the player is loaded. -- This may look pointless, but it prevents articles unlocking "off-screen". local interaction_delay = nil local interaction_enabled = nil function detect_intereaction(typ, obj, name) -- smarts / anomalies / mutants / characters / chraracters_dead / factions / items / artefacts / levels / notes / vehicles if name then create_interaction(typ, name) elseif obj then create_interaction(typ, obj:section()) if IsArtefact(obj) then local kind = ini_sys:r_string_ex(obj:section(),"kind") if (kind ~= "i_attach") and (kind ~= "i_mutant_belt") then create_interaction("artefacts", "about_artefacts") create_interaction("artefacts", obj:section()) end elseif IsStalker(obj) then detect_intereaction("factions", nil, character_community(obj)) end end end function create_interaction(key, section) if (interaction_enabled and key and section and interactivity[key] and interactivity[key][section]) then for k, v in pairs(interactivity[key][section]) do if (key == "notes") then unlock_note(v) else unlock_article(v) end end end end ------------------------------- -- Callbacks ------------------------------- local function actor_on_leave_dialog(id) local character = level.object_by_id(id) detect_intereaction("characters", character) end local function actor_on_item_take(obj) detect_intereaction("items", obj) end local cache_anomaly = {} local mark_anomaly_time = false local anomaly_match = { "zone_field_psychic", "zone_field_radioactive", "zone_burning_fuzz", "zone_field_thermal", "zone_mine_thermal", "zone_zharka_static", "zone_buzz", "zone_mine_chemical", "zone_mine_electric", "zone_witches_galantine", "zone_field_acidic", "zone_mine_acidic", "zone_mine_gravitational_big", "zone_mine_gravitational_strong", "zone_mine_gravitational_average", "zone_mine_gravitational_weak", "fireball_acidic_zone", "fireball_zone", "fireball_electric_zone", "zone_teleport", "lim_space_restrictor_0016" } local function actor_on_feeling_anomaly(obj, flags) if (cache_anomaly[obj:section()]) then return false end -- Return if the player didn't spend 3 hours in the zone if (not mark_anomaly_time) then if (not utils_obj.is_time_spent_in_zone(0,0,2)) then return false elseif (not has_alife_info("actor_spent_2_hrs_in_zone")) then db.actor:give_info_portion("actor_spent_2_hrs_in_zone") mark_anomaly_time = true end end -- Article detection cache_anomaly[obj:section()] = true for i=1,#anomaly_match do if string.find(obj:section(),anomaly_match[i]) then detect_intereaction("anomalies" ,nil, anomaly_match[i]) end end end local function actor_on_first_update() interaction_delay = interaction_delay or time_global() + 7500 end local last_pda_state = false local function actor_on_update() if (interaction_delay and interaction_delay <= time_global()) then -- Entering a vehicle. --RegisterScriptCallback("actor_on_attach_vehicle", detect_vehicle_interaction) -- Talking-to or looting a character. RegisterScriptCallback("actor_on_leave_dialog", actor_on_leave_dialog) -- Taking, using or equipping items. RegisterScriptCallback("actor_on_item_take", actor_on_item_take) -- Anomaly articles. RegisterScriptCallback("actor_on_feeling_anomaly", actor_on_feeling_anomaly) -- We don't need these callbacks anymore. UnregisterScriptCallback("actor_on_first_update", actor_on_first_update) --UnregisterScriptCallback("actor_on_update", actor_on_update) -- Enable guide interactivity. interaction_enabled = true -- Unlock articles the player's faction, equipment and the current level. local faction = character_community(db.actor):sub(7) detect_intereaction("factions", nil, faction) detect_intereaction("levels", nil, level.name()) db.actor:iterate_inventory( function(temp, obj) detect_intereaction("items", obj) end) interaction_delay = nil end -- Turn off Article notification when player opens PDA if (last_pda_state ~= item_device.is_pda_active()) then last_pda_state = item_device.is_pda_active() if last_pda_state then if actor_menu.last_hud_msg(3,"ui_inGame2_notify_article") then actor_menu.set_notification(nil, "ui_inGame2_notify_article", 1) end end end end local function on_game_load() parse_categories() if DEV_DEBUG then init_debug_functions() end end local function save_state(m_data) if (USE_MARSHAL) then if (not m_data.game_statistics) then m_data.game_statistics = {} end m_data.game_statistics.actor_articles = unlocked_articles m_data.game_statistics.actor_notes = unlocked_notes end end local function load_state(m_data) if (USE_MARSHAL) then if (not m_data.game_statistics) then return end unlocked_articles = m_data.game_statistics.actor_articles or unlocked_articles unlocked_notes = m_data.game_statistics.actor_notes or unlocked_notes end end function on_game_start() RegisterScriptCallback("actor_on_interaction",detect_intereaction) RegisterScriptCallback("save_state",save_state) RegisterScriptCallback("load_state",load_state) RegisterScriptCallback("on_game_load",on_game_load) RegisterScriptCallback("actor_on_first_update",actor_on_first_update) RegisterScriptCallback("actor_on_update",actor_on_update) end ------------------------------- -- UI ------------------------------- local SINGLETON = nil function get_ui() SINGLETON = SINGLETON or pda_encyclopedia_tab() return SINGLETON end class "pda_encyclopedia_entry" (CUIListBoxItem) function pda_encyclopedia_entry:__init(sec, indx, clr) super(sec, indx, clr) self.sec = sec self.indx = indx self.clr = clr self.sect = self:GetTextItem() self.sect:SetWndRect(Frect():set(5, 0, 300, 22)) self:SetTextColor(self.clr) self.sect:SetFont(GetFontLetterica18Russian()) self.sect:SetWndSize(vector2():set(400, 22)) self.sect:SetEllipsis(true) self.sect:SetText(game.translate_string( UpdateName(self.sec) )) end class "pda_encyclopedia_tab" (CUIScriptWnd) function pda_encyclopedia_tab:__init() super() -- Interface init. self:InitControls() self:InitCallbacks() self:InitCategories() end function pda_encyclopedia_tab:__finalize() end function pda_encyclopedia_tab:InitControls() local xml = CScriptXmlInit() xml:ParseFile("pda_encyclopedia.xml") -- Main frame. self:SetWndRect(Frect():set(0, 0, 1024, 768)) xml:InitFrame("frame1", self) xml:InitFrame("frame2", self) xml:InitFrame("border", self) xml:InitStatic("frame1:caption", self) -- "Images on top" checkbox. self.image_checkbox = xml:InitCheck("image_checkbox", self) self.image_checkbox:SetCheck(axr_main.config:r_value("pda_encyclopedia", "images_above_text", 1, true)) self:Register(self.image_checkbox, "images_above_text") -- "Show messages" checkbox. self.message_checkbox = xml:InitCheck("message_checkbox", self) self.message_checkbox:SetCheck(axr_main.config:r_value("pda_encyclopedia", "display_messages", 1, true)) self:Register(self.message_checkbox, "display_messages") -- Article and category lists. self.article_list = xml:InitListBox("article_list", self) self:Register(self.article_list, "article_list") self.category_list = xml:InitListBox("category_list", self) self:Register(self.category_list, "category_list") -- Text information, footer image (and container), and the scrollbar. self.information = xml:InitTextWnd("description:information", nil) self.information2 = xml:InitTextWnd("description:information2", nil) self.image_container = xml:InitStatic("description:image_container", nil) self.image = xml:InitStatic("description:image_container:image", self.image_container) self.scrollbar = xml:InitScrollView("description:scrollbar", self) -- Add components to the scrollbar. self.scrollbar:AddWindow(self.information, true) self.scrollbar:AddWindow(self.information2, true) self.scrollbar:AddWindow(self.image_container, true) -- Prevent components being deleted while used. self.information:SetAutoDelete(false) self.information2:SetAutoDelete(false) self.image_container:SetAutoDelete(false) self.image:SetAutoDelete(false) end function pda_encyclopedia_tab:InitCallbacks() self:AddCallback("images_above_text", ui_events.BUTTON_CLICKED, self.SaveCheckBoxSettings, self) self:AddCallback("display_messages", ui_events.BUTTON_CLICKED, self.SaveCheckBoxSettings, self) self:AddCallback("article_list", ui_events.LIST_ITEM_CLICKED, self.SelectArticle, self) self:AddCallback("category_list", ui_events.LIST_ITEM_CLICKED, self.SelectCategory, self) end function pda_encyclopedia_tab:InitArticles(section_c) -- Blank the article list before changing category. self.article_list:RemoveAll() -- Return if the articles table cannot be retrieved. local category for i = 1, #categories do if (categories[i].section == section_c) then category = categories[i] end end local articles = category and category.articles or nil if (not articles) then return end -- Create each article item and add it to the category. local item = nil local section = nil local n = 1 for i = 1, #articles do section = articles[i] if (section) then -- Hide the article's title if it isn't unlocked. if (not locked_articles[section]) and (not locked_notes[section]) then local clr = UpdateColor(section) item = pda_encyclopedia_entry(section, n, clr) self.article_list:AddExistingItem(item) n = n + 1 end end end end function pda_encyclopedia_tab:InitCategories() local item = nil local section = nil local allow = nil local n = 1 self.category_list:RemoveAll() for i = 1, #categories do section = categories[i].section if (section) then local articles = categories[i].articles for j=1,#articles do if (not locked_articles[ articles[j] ]) and (not locked_notes[ articles[j] ]) then allow = true break end end if (allow) then local clr = UpdateColor(section) item = pda_encyclopedia_entry(section, n, clr) self.category_list:AddExistingItem(item) n = n + 1 end allow = false end end end function pda_encyclopedia_tab:Reset() self.scrollbar:Clear() self.article_list:RemoveAll() self:InitCategories() end -- Callbacks function pda_encyclopedia_tab:SaveCheckBoxSettings() -- Write the updated value to axr_options so it is remembered. axr_main.config:w_value("pda_encyclopedia", "images_above_text", self.image_checkbox:GetCheck()) axr_main.config:w_value("pda_encyclopedia", "display_messages", self.message_checkbox:GetCheck()) axr_main.config:save() end function pda_encyclopedia_tab:SelectArticle(section_a) -- Get the selected category and article local item_a, item, section if (section_a) then for index = 0, self.article_list:GetSize()-1 do item = self.article_list:GetItemByIndex(index) if (item.sec == section_a) then self.article_list:SetSelectedIndex(item.indx - 1) section = section_a break end end else item_a = self.article_list:GetSelectedItem() section = item_a.sec end if (not section) then return end -- Load the article text and image if it is unlocked. local locked = (locked_articles[section] ~= nil) and (locked_notes[section] ~= nil) local images_above_text = self.image_checkbox:GetCheck() if (not locked) then -- Set the article's text. local str = game.translate_string(section .. "_text") -- Adjust article's text if its special str = UpdateDescr(section, str) self.information:SetText("%c[0,170,170,170]" .. str) -- Set additional information self.information2:SetText("") local trans = game.translate_string(section .. "_text2") if (trans ~= section .. "_text2") then self.information2:SetText("%c[0,240,240,240]" .. trans) end local section_pic = section --if string.find(section,"encyclopedia_artefacts") then --section_pic = "encyclopedia_artefacts" --end -- Set the article's image. -- A bit hacky, but to allow for dynamic width/height we have to initialise the texture twice. -- We load the texture, grab its dimensions, set the window size then reinitialise it a second time. -- If we don't do this then for whatever weird and wonderful reason the image refuses to draw on the UI. self.image:InitTexture(section_pic .. "_image") -- Grab the dimensions of the image to resize the container. local image_width = self.image:GetTextureRect().x2 - self.image:GetTextureRect().x1 local image_height = self.image:GetTextureRect().y2 - self.image:GetTextureRect().y1 -- Offset is used to add "padding" around the image when text is present. -- If images appear above text and there is no height to the image, then use no offset. local image_offset = images_above_text and (image_height > 0 and 7 or 0) or (image_height > 0 and 15 or 0) -- Resize the image and container, and then reinitialise the texture so it gets drawn. -- The x_coefficient variable is used to fix image stretchiness when using widescreen resolutions. local x_coefficient = (device().height / device().width) / (768 / 1024) self.image_container:SetWndSize(vector2():set(image_width, image_height + image_offset)) self.image:SetWndSize(vector2():set(image_width * x_coefficient, image_height)) self.image:SetStretchTexture(true) self.image:InitTexture(section_pic .. "_image") else self.information:SetText(game.translate_string("pda_encyclopedia_locked_text")) self.information2:SetText("") end -- Same reasoning as the offset for the image height. -- Creates a "better-looking" padding between the text and the image. local information_offset = images_above_text and 10 or 3 -- Adjust the text component size. self.information:AdjustHeightToText() self.information:SetWndSize(vector2():set(self.information:GetWidth(), self.information:GetHeight() + information_offset)) self.information2:AdjustHeightToText() self.information2:SetWndSize(vector2():set(self.information2:GetWidth(), self.information2:GetHeight() + information_offset)) local pos = self.information2:GetWndPos() local pos2 = self.information:GetWndPos() self.information2:SetWndPos(vector2():set(pos.x , pos2.y + self.information:GetHeight() + information_offset + 10)) -- Clear the scrollbar. self.scrollbar:Clear() -- Add the image above text depending on checkbox. if (not locked and images_above_text) then self.scrollbar:AddWindow(self.image_container, true) self.image_container:SetAutoDelete(false) self.image:SetAutoDelete(false) end -- Add the text to the article window. self.scrollbar:AddWindow(self.information, true) self.information:SetAutoDelete(false) self.scrollbar:AddWindow(self.information2, true) self.information2:SetAutoDelete(false) -- Add the image below text depending on checkbox. if not (locked or images_above_text) then self.scrollbar:AddWindow(self.image_container, true) self.image_container:SetAutoDelete(false) self.image:SetAutoDelete(false) end end function pda_encyclopedia_tab:SelectCategory(section_c) local item if section_c then for index = 0, self.category_list:GetSize()-1 do item = self.category_list:GetItemByIndex(index) if (item.sec == section_c) then self.category_list:SetSelectedIndex(item.indx - 1) break end end else item = self.category_list:GetSelectedItem() end if (item) then self:InitArticles(item.sec) self.scrollbar:Clear() end end -- Utility function UpdateColor(section) local clr = utils_xml.get_color("ui_gray_1",true) if (section == "encyclopedia_artefacts__about") or (section == "encyclopedia__notes") or (section == "encyclopedia__notes__ironman") or (section == "encyclopedia__notes__state") then clr = utils_xml.get_color("pda_white",true) end return clr end function UpdateName(section) -- Artefacts if (string.find(section,"encyclopedia_artefacts")) then local art = string.gsub(section,"encyclopedia_artefacts_","") if (ini_sys:section_exist(art)) then section = ui_item.get_sec_name(art) or section end -- Recipes elseif (string.find(section,"encyclopedia__notes_recipe")) then local recipe = string.gsub(section,"encyclopedia__notes_","") if (ini_sys:section_exist(recipe)) then section = ui_item.get_sec_name(recipe) or section end end return section end function UpdateDescr(section, str) -- Equipment State if (section == "encyclopedia__notes__state") then local function fill_list(actor,obj) if (obj) then local con = obj:condition() if (IsWeapon(obj)) or (IsOutfit(obj) or IsHeadgear(obj)) or (obj:section() == "wpn_upd") then local condition = tostring(math.ceil(obj:condition()*100)) local clr if (obj:condition() < 0.25) then clr = utils_xml.get_color("red") elseif (obj:condition() < 0.5) then clr = utils_xml.get_color("orange") elseif (obj:condition() < 0.75) then clr = utils_xml.get_color("yellow") else clr = utils_xml.get_color("green") end local name = ui_item.get_sec_name(obj:section()) str = str .. "\\n%c[0,170,170,170]• " .. name .. ": " .. clr .. condition .. "%" end end end db.actor:iterate_inventory(fill_list,db.actor) -- Ironman States elseif (section == "encyclopedia__notes__ironman") then local ironman = gamemode_ironman.get_ironman_details() if ironman and ironman.death_limit and ironman.death_count then local lives = ironman.death_limit - ironman.death_count local deaths = ironman.granted_lives + ironman.death_count str = str .. utils_xml.get_color("ui_gray_1") .. " \\n• " .. game.translate_string("pda_encyclopedia_ironman_deaths") .. ": " .. utils_xml.get_color("pda_white") .. tostring(deaths) str = str .. utils_xml.get_color("ui_gray_1") .. " \\n• " .. game.translate_string("pda_encyclopedia_ironman_life") .. ": " .. utils_xml.get_color("pda_white") .. tostring(lives) if ironman.life_feature then str = str .. utils_xml.get_color("ui_gray_1") .. " \\n• " .. game.translate_string("pda_encyclopedia_ironman_lifes") .. ": " .. utils_xml.get_color("pda_white") .. tostring(ironman.granted_lives) str = str .. utils_xml.get_color("ui_gray_1") .. " \\n• " .. game.translate_string("pda_encyclopedia_ironman_cycle") .. ": " .. utils_xml.get_color("pda_white") .. tostring(ironman.life_cycle) end local lives_str = clamp(lives,1,3) str = str .. utils_xml.get_color("ui_gray_1") .. " \\n \\n" .. game.translate_string("pda_encyclopedia_ironman_" .. tostring(lives_str)) else str = "" end -- Artefacts elseif (string.find(section,"encyclopedia_artefacts")) then local art = string.gsub(section,"encyclopedia_artefacts_","") if (ini_sys:section_exist(art)) then local tier = ini_sys:r_float_ex(art,"af_rank") if (art == "af_compass") or (art == "af_oasis_heart") then tier = 3 end local weight = ini_sys:r_float_ex(art,"inv_weight") -- Description str = " \\n" .. utils_xml.get_color("pda_blue") .. game.translate_string("pda_encyclopedia_subject") str = str .. utils_xml.get_color("ui_gray_1") .. " \\n• " .. game.translate_string("pda_encyclopedia_name") .. ": " .. utils_xml.get_color("pda_white") .. ui_item.get_sec_name(art) str = str .. utils_xml.get_color("ui_gray_1") .. " \\n• " .. game.translate_string("pda_encyclopedia_tier") .. ": " .. utils_xml.get_color("pda_white") .. game.translate_string("pda_encyclopedia_tier_" .. tostring(tier)) str = str .. utils_xml.get_color("ui_gray_1") .. " \\n• " .. game.translate_string("pda_encyclopedia_weight") .. ": " .. utils_xml.get_color("pda_white") .. tostring(weight) .. " " .. game.translate_string("st_kg") str = str .. " \\n" .. " \\n" .. utils_xml.get_color("pda_green") .. game.translate_string("pda_encyclopedia_info") str = str .. " \\n" .. utils_xml.get_color("ui_gray_1") .. ui_item.get_sec_desc(art) str = str .. " \\n" .. " \\n" .. utils_xml.get_color("pda_yellow") .. game.translate_string("pda_encyclopedia_properties") str = str .. " \\n" .. utils_xml.get_color("ui_gray_1") local states = utils_ui.get_stats_table(art) for name,gr in spairs( states, utils_ui.sort_by_index ) do local value, ng = utils_ui.get_stats_string_value(nil, art, gr, name, true) if value then local clr = ng and "%c[0,255,100,100]" or "%c[0,250,250,250]" str = str .. "\\n " .. utils_xml.get_color("ui_gray_1") .. "• " .. game.translate_string(gr.name) .. ": " .. clr .. tostring(value) end end end -- Recipes elseif (string.find(section,"encyclopedia__notes_recipe")) then local recipe = string.gsub(section,"encyclopedia__notes_","") if not (ini_sys:section_exist(recipe) and IsItem("recipe",recipe)) then return str end str = str .. "\\n \\n" .. utils_xml.get_color("pda_yellow") .. game.translate_string("pda_encyclopedia_content") local ini_craft = itms_manager.ini_craft local ind = 1 while ini_craft:section_exist(tostring(ind)) do local ind_str = tostring(ind) local n = ini_craft:line_count(ind_str) or 0 for i=0, n-1 do local result, id, value = ini_craft:r_line(ind_str , i , "", "") id = string.sub(id,3) if ini_sys:section_exist(id) then local t = str_explode(value,",") if (t[2] == recipe) then str = str .. "\\n \\n" .. utils_xml.get_color("pda_white") .. ui_item.get_sec_name(id) .. ":" if (#t == 6) or (#t == 8) or (#t == 10) then local tool = tonumber(t[1]) or 1 if t[3] and t[4] then -- support item 1 if ini_sys:section_exist(tostring(t[3])) then str = str .. "\\n" .. utils_xml.get_color("ui_gray_1") .. "• " .. ui_item.get_sec_name(t[3]) .. utils_xml.get_color("pda_white") .. " (x" .. tostring(t[4]) .. ")" end end if t[5] and t[6] then -- support item 2 if ini_sys:section_exist(tostring(t[5])) then str = str .. "\\n" .. utils_xml.get_color("ui_gray_1") .. "• " .. ui_item.get_sec_name(t[5]) .. utils_xml.get_color("pda_white") .. " (x" .. tostring(t[6]) .. ")" end end if t[7] and t[8] then -- support item 3 if ini_sys:section_exist(tostring(t[7])) then str = str .. "\\n" .. utils_xml.get_color("ui_gray_1") .. "• " .. ui_item.get_sec_name(t[7]) .. utils_xml.get_color("pda_white") .. " (x" .. tostring(t[8]) .. ")" end end if t[9] and t[10] then -- support item 4 if ini_sys:section_exist(tostring(t[9])) then str = str .. "\\n" .. utils_xml.get_color("ui_gray_1") .. "• " .. ui_item.get_sec_name(t[9]) .. utils_xml.get_color("pda_white") .. " (x" .. tostring(t[10]) .. ")" end end end end end end ind = ind + 1 end -- Storylines elseif (string.find(section,"encyclopedia__notes_living_legend")) or (string.find(section,"encyclopedia__notes_mortal_sin")) then local comm = get_actor_true_community() local f = faction_expansions.faction[comm]["leader_name"] local leader_name = f and f["leader_name"] or "st_dyn_news_someone" str = strformat(str, game.translate_string(leader_name)) end return str end ------------------------------- -- Debug ------------------------------- function init_debug_functions() -- Debug Commands local CMD = debug_cmd_list.command_get_list() function CMD.unlock_all_articles(_,__,x) local result = unlock_all_articles() if (not result) then x:SendOutput('!All articles are already unlocked') return end local ui = get_ui() if ui then ui:Reset() end x:SendOutput('-Unlocked all %s articles', result) end function CMD.unlock_all_notes(_,__,x) local result = unlock_all_notes() if (not result) then x:SendOutput('!All notes are already unlocked') return end local ui = get_ui() if ui then ui:Reset() end x:SendOutput('-Unlocked all %s notes', result) end -- Debug Launcher executions ui_debug_launcher.inject("action", { name = "Unlock all articles" , cmd = "unlock_all_articles" , hide_ui = 2 } ) ui_debug_launcher.inject("action", { name = "Unlock all notes" , cmd = "unlock_all_notes" , hide_ui = 2 } ) end